<!DOCTYPE html>
<html>
<head>
    <title>Supply</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link  href="<?php echo base_url();?>css/admin.css" rel="stylesheet" type="text/css" />

	<!-- 1. Add these JavaScript inclusions in the head of your page -->
		<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
		<script type="text/javascript" src="<?php echo base_url();?>js/highchart/js/highcharts.js"></script>
		
		<!-- 1a) Optional: add a theme file -->
		<!--
			<script type="text/javascript" src="<?php echo base_url();?>js/highchart/js/themes/gray.js"></script>
		-->
		
		<!-- 1b) Optional: the exporting module -->
		<script type="text/javascript" src="<?php echo base_url();?>js/highchart/js/modules/exporting.js"></script>
		
		
		<!-- 2. Add the JavaScript to initialize the chart on document ready -->
		<script type="text/javascript">
		
			var chart;
			$(document).ready(function() {
				chart = new Highcharts.Chart({
					chart: {
						renderTo: 'container',
						type: 'line'
					},
					title: {
						text: 'Supply'
					},
					subtitle: {
						<?php
							if($graphoption == 'summary-pay'){
								echo "text: 'ราคาวัตถุดิบที่รับซื้อ'";
							}else if($graphoption == 'summary-wg'){
								echo "text: 'น้ำหนักวัตถุดิบที่รับซื้อ'";
							}
						?>
						//text: 'An example of irregular time data in Highcharts JS'	
					},
					xAxis: {
						type: 'datetime',
						dateTimeLabelFormats: { // don't display the dummy year
						second: '%H:%M:%S',
						minute: '%H:%M',
						hour: '%H:%M',
						day: '%e. %b',
						week: '%e. %b',
						month: '%b \'%y',
						year: '%Y'
						}
					},
					yAxis: {
						title: {
							<?php
								if($graphoption == 'summary-pay'){
									echo "text: 'ราคาวัตถุดิบที่รับซื้อ (บาท)'";
								}else if($graphoption == 'summary-wg'){
									echo "text: 'น้ำหนักวัตถุดิบที่รับซื้อ (กิโลกรัม)'";
								}
							?>
							//text: 'Snow depth (m)'
						},
						min: 0
					},
					tooltip: {
						formatter: function() {
				                return '<b>'+ this.series.name +'</b><br/>'+
								Highcharts.dateFormat('%Y-%m-%e %H:%M:%S', this.x) +': '+ this.y+'        .';
						}
					},
					series: [
	<?php
		foreach ($dat as $larnname => $arr):
	?>	{
			name: '<?=$larnname;?>',
			
			data: [
			<?php foreach($arr as $dateandtotal): ?>
			
				[<?="{$dateandtotal['dateupload']}";?> , <?=$dateandtotal['total'];?> ],
				
			<?php endforeach;?>
			],
			color: '<?php echo $poscolor[$larnname];?>'
		},
	<?php	
		endforeach;
	?>

					]
				});
				
				
			});
				
		</script>
     
</head>
<body>

 <div id="contentright">
        <div id="search">
          <div id="searchblank">
            <div id="searchinput">
             Welcome, admin
            </div>
          
            <div id="advancesearch"><a href="#" class="advancesearch">Logout</a></div>
          </div>
        </div>
        </div>
    <div id="main">
       <?php 
        $menu['nowmenu'] = 'supplies';
        $this->load->view('common/divheader',$menu);
        ?>
        <div id="middle">
        <div id="breadcrumbs"><a href="dashboard.html">Dashboard</a>/ Supplies</div>
            <?php $this->load->view('manager/divleftmenu');?>
            <div id="center-column">
            <h1>Supply-Realtime</h1>
               <div class="top-bar">
                <ul id="top-selector">
                <li><a href="<?php echo site_url('manager/realtime');?>">Realtime</a></li>
                <li><a href="<?php echo site_url('manager/summary');?>">Summary</a></li>
               <li><a href="<?php echo site_url('manager/range');?>">Range</a></li>
            
            </ul>
                    
            </div>
                <div class="select-bar">
                    <p>
                      <a href="<?php echo site_url('manager/realtime/summary-pay')?>">ราคารับซื้อ</a>|
                      <a href="<?php echo site_url('manager/realtime/summary-wg')?>">ปริมาณรับซื้อ</a>
                    </p>
              </div>
              
              
              <p><div id="container" style="width: 700px; height: 400px; margin: 0 auto"></div></p>
              
              <div class="table">
                <table class="listing" cellpadding="0" cellspacing="0">
                        <thead>
    		<tr>
    			<th>Date/time</th>
    			<th>ลาน</th>
    			<th>น้ำหนักทั้งหมด</th>
    			<th>เงินจ่ายสุทธิ</th>
    			<th>เงินโปรโมชั่น</th>
    			<th>เงินจ่าย+โปรโมชั่น</th>
    		</tr>
    	</thead>
                        <tbody>
    		<?php 
    			foreach ($realtimeUpload as $row):
    		?>
    				<tr class="style2">
    					<td><?php echo $row['dateupload'];?> </td>
    					<td><?php echo $row['posname'];?> </td>
    					<td><?php echo $row['sum_netwg'];?> </td>
    					<td><?php echo $row['sum_netbuy'];?></td>
    					<td><?php echo $row['sum_promo'];?></td>
    					<td><?php echo $row['sum_netbuy']+$row['sum_promo'];?></td>
    				</tr>
    		<?php 	
    			endforeach;
    		?>
    	
    	</tbody>
                    </table>
                    
              </div>
            </div>
            <div id="right-column">
                <strong class="h">Quick Link</strong>
                <div class="box">This is your admin home page. It will give you access to all things within the back end system that you will need to facilitate a smooth operation.</div>
            </div>
        </div>
        <div id="footer"><p>ALL RIGHTS RESERVED 2012 <a href="http://www.ubonbioethanol.com">UBON BIO ETHANOL CO., LTD.</a><br>Developed by DASH CO., LTD (2011-2012).  </p></div>
    </div>
</body>
</html>